package main

import "fmt"

type MySlice[T int | string] []T

func (s MySlice[T]) Sum() T {
	var sum T
	for _, value := range s {
		sum += value
	}
	return sum
}
func main() {

	s1 := MySlice[int]{1, 2, 3}
	fmt.Println(s1.Sum())

	s2 := MySlice[string]{"a", "love", "b"}
	fmt.Println(s2.Sum())

}
